package com.heu.blood.analysis.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.heu.blood.analysis.entity.TestResult;
import com.heu.blood.analysis.vo.BloodSampleInpatientlabReportVo;
import com.heu.blood.common.aop.ControllerLogAnnotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.heu.blood.analysis.entity.BloodTestInpatientlabEntity;
import com.heu.blood.analysis.service.BloodTestInpatientlabService;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;



/**
 * 入院检查患者的血液检验表
 *
 * @author lhh
 * @email lhh1612325771@163.com
 * @date 2023-11-29 20:41:10
 */
@RestController
@RequestMapping("analysis/bloodtestinpatientlab")
public class BloodTestInpatientlabController {
    @Autowired
    private BloodTestInpatientlabService bloodTestInpatientlabService;

//    /**
//     * 列表
//     */
//    @RequestMapping("/list")
//    public R list(@RequestParam Map<String, Object> params){
//        PageUtils page = bloodTestInpatientlabService.queryPage(params);
//
//        return R.ok().put("page", page);
//    }

    /**
     * 分页联表条件查询入院检查患者血液样本和检测结果
     * @param params
     * @return
     */
    @RequestMapping("/selectSampleTestPage")
    @ControllerLogAnnotation(module = "入院检查患者的血液检验", operate = "分页联表条件查询入院检查患者血液样本和检测结果")
    public R selectSampleTestPage(@RequestParam Map<String, Object> params){
        PageUtils page = bloodTestInpatientlabService.selectSampleTestPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 查询血液样本检测报告
     * @param bloodSampleId
     * @return
     */
    @GetMapping("/queryTestResult")
    @ControllerLogAnnotation(module = "入院检查患者的血液检验", operate = "查询血液样本检测报告")
    public R queryTestResult(String bloodSampleId){
        Map<BloodSampleInpatientlabReportVo, List<TestResult>> report =  bloodTestInpatientlabService.queryTestResult(bloodSampleId);
        return R.ok().put("map", report);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ControllerLogAnnotation(module = "入院检查患者的血液检验", operate = "根据id查询入院检查患者的血液检验信息")
    public R info(@PathVariable("id") Integer id){
		BloodTestInpatientlabEntity bloodTestInpatientlab = bloodTestInpatientlabService.getById(id);

        return R.ok().put("data", bloodTestInpatientlab);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ControllerLogAnnotation(module = "入院检查患者的血液检验", operate = "保存入院检查患者的血液检验信息")
    public R save(@RequestBody List<BloodTestInpatientlabEntity> bloodTestInpatientlab){
		bloodTestInpatientlabService.saveBatch(bloodTestInpatientlab);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ControllerLogAnnotation(module = "入院检查患者的血液检验", operate = "更新入院检查患者的血液检验信息")
    public R update(@RequestBody List<BloodTestInpatientlabEntity> bloodTestInpatientlab){
		bloodTestInpatientlabService.updateBatchById(bloodTestInpatientlab);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ControllerLogAnnotation(module = "入院检查患者的血液检验", operate = "根据id删除入院检查患者的血液检验信息")
    public R delete(@RequestBody Integer[] ids){
		bloodTestInpatientlabService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
